package com.test.common;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import com.kylinhunter.ui.common.DeskTopPanelInternalFrame;
import com.kylinhunter.ui.common.KHDesktop;
import com.kylinhunter.ui.common.KHDesktopPanelFactory;

public class JFrameWithDesktop  extends JFrame{
	KHDesktop  kd=new KHDesktopPanelFactory().getDesktop("desktoppanel");
	private WindowListener closeListener=new WindowAdapter(){
		public void windowClosing(WindowEvent e) {

			System.exit(0);
		}
	};	
	public JFrameWithDesktop() {
		super();
		// TODO Auto-generated constructor stub
		
		 
		this.setLayout(new BorderLayout());
		this.addWindowListener(closeListener);	
		
		this.add((JPanel)kd,BorderLayout.CENTER);
		this.setSize(new Dimension(600,400));
		this.setVisible(true);
		this.setLocationRelativeTo(null);
	}
	
	public void addDeskTopPanelInternalFrame( DeskTopPanelInternalFrame windows) {
		// TODO Auto-generated method stub
		DeskTopPanelInternalFrame window=windows;
		window.setWindows_id(window.getTitle());
        kd.addWindow(window);
	}

	public WindowListener getCloseListener() {
		return closeListener;
	}

	public void setCloseListener(WindowListener closeListener) {
		this.closeListener = closeListener;
	}

}
